<?php

namespace App\Admin\Controllers;

use App\Admin\Repositories\CoImg;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Controllers\AdminController;

class CoImgController extends AdminController
{
    protected $title ='首页图片';
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new CoImg(), function (Grid $grid) {
            $grid->id->sortable();
            $grid->url->image('',80,80);

            $grid->filter(function (Grid\Filter $filter) {
                $filter->equal('id');

            });
            $grid->disableDeleteButton();
            $grid->disableViewButton();
            $grid->disableCreateButton();
        });
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     *
     * @return Show
     */
    protected function detail($id)
    {
        return Show::make($id, new CoImg(), function (Show $show) {
            $show->id;
            $show->url;
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new CoImg(), function (Form $form) {
            $form->display('id');
            $form->image('url')->required()->help('尺寸比例 宽：750 高：260');
            $form->disableViewButton();
            $form->disableDeleteButton();
            $form->footer(function ($footer) {
                // 去掉`重置`按钮
                $footer->disableReset();

                // 去掉`查看`checkbox
                $footer->disableViewCheck();

                // 去掉`继续编辑`checkbox
                $footer->disableEditingCheck();

                // 去掉`继续创建`checkbox
                $footer->disableCreatingCheck();
            });
        });
    }
}
